#tag Class
Protected Class Tago
Inherits Application
	#tag Event
		Sub Open()
		  // const kCRLF = \"\x0D\x0A"
		  #if TargetLinux then
		    MsgBox("This application does not run on Linux" + EndOfLine + "Stay tuned for a Linux version soon")
		  #endif
		  
		  _d_prefs = new dictionary
		  _d_ratings_misc_for_show = new dictionary
		  
		  _enable_rdns = 0
		  _dict_exact_series_name_to_seriesid = new dictionary
		  _dict_series_names_search = new dictionary
		  _dict_savedxml = new dictionary
		  
		  _dict_showingBits = new dictionary
		  
		  _dict_showingBits.value("1") = "CC"
		  _dict_showingBits.value("2") = "Stereo"
		  _dict_showingBits.value("4") = "Subtitled"
		  _dict_showingBits.value("8") = "In Prog"
		  _dict_showingBits.value("16") = "Classroom"
		  _dict_showingBits.value("32") = "SAP"
		  _dict_showingBits.value("64") = "Blackout"
		  _dict_showingBits.value("128") = "Intercast"
		  _dict_showingBits.value("256") = "3D"
		  _dict_showingBits.value("512") = "Repeat"
		  _dict_showingBits.value("1024") = "Letterbox"
		  _dict_showingBits.value("4096") = "HD"
		  _dict_showingBits.value("65536") = "Sex"
		  _dict_showingBits.value("131072") = "Violence"
		  _dict_showingBits.value("262144") = "Language"
		  _dict_showingBits.value("524288") = "Dialog"
		  _dict_showingBits.value("1048576") = "Fantasy Violence"
		  
		  _dict_seriesid_files = new dictionary
		  
		  _application_location = GetFolderItem("")
		  
		  if _application_location = nil then
		    MsgBox("Error setting location CurrentWorkingDirectory - MPEG-4 tag reading/writing not possible.")
		  else
		    dim f as FolderItem
		    #if TargetWin32 then
		      f = GetFolderItem(_application_location.AbsolutePath + "AtomicParsley-win32-0.9.0")
		    #else
		      #if TargetMacOS then
		        f = GetFolderItem(_application_location.AbsolutePath + "AtomicParsley-MacOSX-0.9.0")
		      #endif
		    #endif
		    if f = nil then
		    else
		      #if TargetWin32 then
		        _atomic_parsley_location = f.AbsolutePath + "AtomicParsley.exe"
		      #endif
		      #if TargetMacOS then
		        //_atomic_parsley_location = f.AbsolutePath + "AtomicParsley64"
		        // _atomic_parsley_location = f.AbsolutePath + "AtomicParsley32"
		        _atomic_parsley_location = f.AbsolutePath + "AtomicParsley"
		      #endif
		      if _atomic_parsley_location <> "" then
		        f = GetFolderItem(_atomic_parsley_location)
		        if f = nil then
		          MsgBox("Could not locate " + _atomic_parsley_location  + " - MPEG-4 tag reading/writing not possible.")
		        else
		          // MsgBox("Got AtomicParsley item location")
		        end if
		      else
		        MsgBox("Could not find Atomic Parsley folder - MPEG-4 tag reading/writing not possible.")
		      end if
		    end if
		  end if
		  
		  
		  dim appdataf as folderitem = GetFolderItem(SpecialFolder.ApplicationData.AbsolutePath + "Tago")
		  if not appdataf.Exists then
		    appdataf.CreateAsFolder
		    if not appdataf.Exists then
		      MsgBox("Could not create AppData folder at: " + appdataf.AbsolutePath)
		      exit
		    end if
		  end if
		  
		  _prefsdatafile = GetFolderItem(appdataf.AbsolutePath + "prefs")
		  if not _prefsdatafile.Exists then
		    // nothing
		  else
		    // read it in
		    dim loaded as boolean = _d_prefs.LoadXML(_prefsdatafile)
		  end if
		End Sub
	#tag EndEvent

	#tag Event
		Sub OpenDocument(item As FolderItem)
		  populate_listbox_with_folder_contents(item,0)
		  
		End Sub
	#tag EndEvent


	#tag Constant, Name = kEditClear, Type = String, Dynamic = False, Default = \"&Delete", Scope = Public
		#Tag Instance, Platform = Windows, Language = Default, Definition  = \"&Delete"
		#Tag Instance, Platform = Linux, Language = Default, Definition  = \"&Delete"
	#tag EndConstant

	#tag Constant, Name = kFileQuit, Type = String, Dynamic = False, Default = \"&Quit", Scope = Public
		#Tag Instance, Platform = Windows, Language = Default, Definition  = \"E&xit"
	#tag EndConstant

	#tag Constant, Name = kFileQuitShortcut, Type = String, Dynamic = False, Default = \"", Scope = Public
		#Tag Instance, Platform = Mac OS, Language = Default, Definition  = \"Cmd+Q"
		#Tag Instance, Platform = Linux, Language = Default, Definition  = \"Ctrl+Q"
	#tag EndConstant


	#tag ViewBehavior
	#tag EndViewBehavior
End Class
#tag EndClass
